package key.dao.impl;

import key.dao.TypeDao;
import key.entity.Type;
import key.util.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class TypeDaoImpl implements TypeDao {

    @Override
    public List<Type> selectAll() throws SQLException {

        QueryRunner queryRunner = new QueryRunner(DbUtils.getDataSource());

        String sql = "select t_id tid,t_name tname ,t_info tinfo from type limit 5";

        List<Type> list = queryRunner.query(sql, new BeanListHandler<>(Type.class));
        return list;
    }
}
